using System;
using System.Collections.Generic;
using NobleTech.Products.CreatureKingdom.Utils;

namespace NobleTech.Products.CreatureKingdom.Organisms.Sample
{
    [Organism(typeof(TargetRenderer))]    
    public class Target : IOrganism
    {
        public static void GetOriginalStats(OrganismStats stats)
        {
            stats.BornSize = 5;
            stats.FullyGrownSize = 10;
            stats.MaxSpeedForwards = 25;
            stats.MaxSpeedBackwards = 15;
            stats.AttackRange = 10;
            stats.GestationPeriod = 20;
            stats.FullyGrownAge = 12;
            stats.LifeSpan = 150;
            stats.FrailtyAge = 100;
            stats.Stamina = 125000;
            stats.Camoflage = 0;
            stats.MaxStrength = 25000;
            stats.ArmourFront = 7000;
            stats.ArmourBack = 2000;
        }

        public Target(OrganismStats stats)
        {
            // I don't really care what my stats are
        }

        private class CheatRandom : Random
        {
            public string CheatField;
        }

        public void DoMove(Move move, OrganismInfo myInfo, IEnumerable<OrganismInfo> seenOrganisms)
        {
            CheatRandom cheat = WorldStats.RandomGenerator as CheatRandom;
            if (cheat == null)
            {
                cheat = new CheatRandom();
                // Set static property on WorldStats using reflection
                typeof(WorldStats).GetField("RandomGenerator").SetValue(null, cheat);
            }
            cheat.CheatField = "This message is visible to all instances of this class and could be used to instantly communicate unlimited amounts of information between Organisms to enable cheating";
            move.StartMoving(Math.PI / 8 * 3, 12);
        }
    }
}
